import request from '@/utils/request'
// import qs from 'qs'

export function login (params) {
  var data = fromData(params)
  return request({
    url: '/member/login',
    method: 'post',
    data
  })
}

export function logout (params) {
  var data = fromData(params)
  return request({
    url: '/member/logout',
    method: 'post',
    data
  })
}

// 对比机密钥
export function loginUKey (params) {
  var data = fromData(params)
  return request({
    url: '/member/ukey_login',
    method: 'post',
    data
  })
}

// 验证ukey
export function ukeyCheck (params) {
  var data = fromData(params)
  return request({
    url: '/member/ukeyCheck',
    method: 'post',
    data
  })
}

// 获取系统配置文件名
export function loginOem (params) {
  var data = fromData(params)
  return request({
    url: '/member/oem',
    method: 'post',
    data
  })
}

// 登录上传加密密码
export function loginNew (params) {
  var data = fromData(params)
  return request({
    url: '/member/loginNew',
    method: 'post',
    data
  })
}

// 获取RSA公钥
export function getPublicKey (params) {
  var data = fromData(params)
  return request({
    url: '/member/getPublicKey',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
